﻿using System;
using System.Configuration;
using System.Web.UI.WebControls;
using EPiServer.UI;

namespace EPiServer.Municipality.Web.UI.PropertyControls.Dialogs {
    /// <summary>
    /// 
    /// </summary>
    /// <remarks></remarks>
    /// <example></example>
    public partial class GoogleMapsLocationSelection : SystemPageBase {
        protected HiddenField HiddenFieldLocation;

        /* *******************************************************************
        * Properties
        * *******************************************************************/
        #region protected string DefaultCenter
        /// <summary>
        /// Gets the DefaultCenter of the GoogleMapsLocationSelection
        /// </summary>
        /// <value></value>
        protected string DefaultCenter
        {
            get
            {
                string defaultCenter = ConfigurationManager.AppSettings["GoogleMapsLocationDefaultCenter"];

                if (string.IsNullOrEmpty(defaultCenter))
                    defaultCenter = "59.3239999,18.0753597";

                return defaultCenter;
            }
        }
        #endregion
        #region protected string DefaultZoomLevel
        /// <summary>
        /// Gets the DefaultZoomLevel of the GoogleMapsLocationSelection
        /// </summary>
        /// <value></value>
        protected string DefaultZoomLevel
        {
            get
            {
                string defaultCenter = ConfigurationManager.AppSettings["GoogleMapsLocationDefaultZoomLevel"];

                if (string.IsNullOrEmpty(defaultCenter))
                    defaultCenter = "5";

                return defaultCenter;
            }
        }
        #endregion
        #region protected string CurrentLocationZoomLevel
        /// <summary>
        /// Gets the CurrentLocationZoomLevel of the GoogleMapsLocationSelection
        /// </summary>
        /// <value></value>
        protected string CurrentLocationZoomLevel
        {
            get
            {
                string currentZoomLevel = ConfigurationManager.AppSettings["GoogleMapsLocationCurrentLocationZoomLevel"];

                if (string.IsNullOrEmpty(currentZoomLevel))
                    currentZoomLevel = "15";

                return currentZoomLevel;
            }
        }
        #endregion

        /* *******************************************************************
        * Event methods
        * *******************************************************************/
        #region protected override void OnPreInit(EventArgs e)
        /// <summary>
        /// 
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            MasterPageFile = EPiServer.Configuration.Settings.Instance.UIUrl + "MasterPages/EPiServerUI.master";
        }
        #endregion
        #region protected void Page_Load(object sender, EventArgs e)
        /// <summary>
        /// This method is called when the Page's Load event has been fired.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> that fired the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> of the event.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            HiddenFieldLocation.Value = Request.QueryString["value"];
        }
        #endregion
    }
}